package muilty_thread.atomic;

import java.util.concurrent.atomic.AtomicLongArray;

public class LongArrayTest {


    public static void main(String[] args) {
        long[] arrLong = new long[] {10, 20, 30, 40, 50};
        AtomicLongArray atomicLongArray = new AtomicLongArray(arrLong);
        for (int i = 0; i < atomicLongArray.length(); i++) {
            System.out.println(atomicLongArray.get(i));
        }

        System.out.println("--------------------");

        System.out.println(atomicLongArray.getAndAdd(0, 12));
        System.out.println(atomicLongArray.get(0));

        System.out.println(atomicLongArray.compareAndSet(0, 22, 23));
        System.out.println(atomicLongArray.compareAndSet(0, 22, 23));
        System.out.println(atomicLongArray.get(0));


    }
}
